<?php

    class Custom_Fields extends ActiveRecord {
        
        function _setup()
        {
            $this->table = DB_PREFIX.'custom_fields';
        }
        
        function validate()
        {
            $this->validates_presence_of(array('field_key','field_type'));
            $this->validates_uniqueness_of('field_key');
        }
        
        function &get_paged_report()
        {
            $sql = "SELECT * from `{$this->table}`";
            $pager = $this->pager($sql);
            $pager->row_key = 'id';
            return $pager;
        }
        
        function assoc()
        {
            return $this->db->GetAssoc("select id, field_key from `{$this->table}` order by field_key");
        }        
    }

?>